package com.lemon.smartsafetynew.ui.activity.record;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppManager;
import com.lemon.smartsafetynew.entity.record.CompanyPeopleVo;
import com.lemon.smartsafetynew.entity.record.SpaceVo;
import com.lemon.smartsafetynew.ui.activity.base.SwipeBackActivity;
import com.lemon.smartsafetynew.ui.adapter.record.CompanyPeopleAdapter;
import com.lemon.smartsafetynew.util.common.CommonUtil;
import com.lemon.smartsafetynew.util.constants.KeyConstants;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 受限空间详情
 * Created by JiangAn on 2018/5/23.
 */

public class RecordSpaceDetailActivity extends SwipeBackActivity {
    @Bind(R.id.iv_return)
    ImageView ivReturn;
    @Bind(R.id.tv_space_name)
    TextView tvSpaceName;
    @Bind(R.id.tv_space_number)
    TextView tvSpaceNumber;
    @Bind(R.id.tv_main_danger_thing)
    TextView tvMainDangerThing;
    @Bind(R.id.tv_cause_danger_type)
    TextView tvCauseDangerType;
    @Bind(R.id.tv_space_address)
    TextView tvSpaceAddress;
    @Bind(R.id.tv_safe_equipment)
    TextView tvSafeEquipment;
    @Bind(R.id.tv_space_remark)
    TextView tvSpaceRemark;

    private static SpaceVo data;
    private Boolean isShowReturn = false;

    @Override
    protected void initTitle() {
        this.setBarTitle(getString(R.string.record_space));
    }

    @Override
    protected void getBundleArgs() {
        super.getBundleArgs();

        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            data = (SpaceVo) bundle.getSerializable(KeyConstants.KEY_SPACE_VO);
            isShowReturn = bundle.getBoolean("isShowReturn");
        }
    }

    @Override
    protected void callFinish() {
        AppManager.getAppManager().finishActivity(RecordSpaceDetailActivity.this);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_record_space_detail;
    }

    @Override
    protected void initViews() {
        super.initViews();
        if (isShowReturn) {
            ivReturn.setVisibility(View.VISIBLE);
        } else {
            ivReturn.setVisibility(View.INVISIBLE);
        }
        if(data != null) {
            tvSpaceName.setText(CommonUtil.avoidNullString(data.getName()));
            tvSpaceNumber.setText(CommonUtil.avoidNullString(data.getNumber()));
            tvMainDangerThing.setText(CommonUtil.avoidNullString(data.getMainHazardous()));
            tvCauseDangerType.setText(CommonUtil.avoidNullString(data.getAccidentProne()));
            tvSpaceAddress.setText(CommonUtil.avoidNullString(data.getPosition()));
            tvSafeEquipment.setText(CommonUtil.avoidNullString(data.getSafetyMeasures()));
            tvSpaceRemark.setText(CommonUtil.avoidNullString(data.getRemark()));
        }
    }

    @Override
    protected void initListener() {
        super.initListener();
        ivReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppManager.getAppManager().finishActivity(RecordSpaceDetailActivity.this);
                AppManager.getAppManager().finishActivity(RecordSpaceActivity.class);
            }
        });
    }
}

